var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var $http = function (op) {
    var header = { "Content-Type": op.method.toUpperCase() == 'POST' ? "application/x-www-form-urlencoded" : "application/json" };
    return new Promise(function (fn1, fn2) {
        wx.request(__assign(__assign({}, op), { header: header,
            success: function (_a) {
                var data = _a.data;
                fn1(data);
            },
            fail: function (err) {
                fn2(err);
            } }));
    });
};
var $login = function (op) {
    return new Promise(function (fn1, fn2) {
        wx.login(__assign(__assign({}, op), { success: function (res) {
                fn1(res);
            },
            fail: function (err) { fn2(err); } }));
    });
};
module.exports = {
    $http: $http,
    $login: $login
};
